﻿using UnityEngine;
using System.Collections;

public class DisplaySmiles : MonoBehaviour {

  public Transform target;//Empty game object atatached to  buildings.
  Vector3 screenPos;//postion on the screen of the image
  Texture2D img;//image that will be displayed
  public Texture2D isGreat, isGood, isNutral, isBad, isAwefull;//holds the smiles
  public string gameInfo;//game hint message
  public bool showBool;//shows the smile
  public float smileTimer;//time for the smile

	// Update is called once per frame
	void Update () {
    if (smileTimer > 0)
    {
      smileTimer -= Time.deltaTime;
    }
    if (smileTimer <= 0)
    {
      showBool = false;
    }
	
	}

  void OnGUI()
  {
    if (showBool)
    {
      GUI.Label(new Rect(screenPos.x, screenPos.y, 50, 50), img);
      GUI.Label(new Rect(500, 100, 100, 25), gameInfo);
    }
  }


  public void smileTimerFunction(Vector3 buildingPos, int smileType, float Timer)
  {
    //set screen postion
    screenPos = camera.WorldToScreenPoint(buildingPos);
    screenPos.y = (screenPos.y - Screen.height) * -1;

    //chose the smile
    switch (smileType)
    {
      case 1:
        img = isGreat;
        break;
      case 2:
        img = isGood;
        break;
      case 3:
        img = isNutral;
        break;
      case 4:
        img = isBad;
        break;
      case 5:
        img = isAwefull;
        break;
      default:
        img = null;
        break;
    }

    //set the countdown timer
    Timer -= Time.deltaTime;
    if (Timer >= 0)
    {
      showBool = true;
    }
    else
    {
      showBool = false;
    }
    smileTimer = Timer;
  }
}
